import JDBCUtil.JDBCUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Test {
    public static void main(String[] args) {
        try {
            getList();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
    public static void getList(){
        Connection conn = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        try {
            conn = JDBCUtil.getConnection();
            String sql = "select  name , email from birthdays";
            preparedStatement = conn.prepareStatement(sql);
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()){
                String name = resultSet.getString("name");
                String email = resultSet.getString("email");

                send(name,email);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            JDBCUtil.close(conn,preparedStatement,resultSet);
        }

    }
    public static void send(String name,String eamil){
        //"1208805378","1565383429","2567071757","1474719254"

            String userName = "396402252@qq.com";  //发送人邮箱
            String addressee = eamil+"@qq.com"; //收件人邮箱
            String subject = "感恩节快乐";             //邮件主题
            String massage = "思念是一首诗写在最深情的午夜，" +
                    "感激是一首歌在最思念的日子唱响，" +
                    "你是一辈子无法忘记的人，" +
                    "感谢你出现在我生命里。感恩节快乐。";    //邮件内容
            MyEmail.emailsend(userName, addressee, subject, massage);
    }
}
